//package com.gitlab.lucky.common.security.service;
//
//import com.gitlab.lucky.admin.service.AdminAuthorityService;
//import com.gitlab.lucky.admin.service.AdminRoleService;
//import com.gitlab.lucky.common.dao.model.AdminAuthority;
//import com.gitlab.lucky.common.dao.model.AdminRole;
//import com.gitlab.lucky.common.dao.model.PlatformData;
//import com.gitlab.lucky.common.security.config.JwtUser;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.GrantedAuthority;
//import org.springframework.security.core.authority.SimpleGrantedAuthority;
//import org.springframework.stereotype.Service;
//import java.util.*;
//
//@Service
//public class JwtPermissionService {
//
//    @Autowired
//    private AdminRoleService adminRoleService;
//
//    @Autowired
//    private AdminAuthorityService adminAuthorityService;
//
//    /**
//     * 获取用户权限
//     * @param jwtUser
//     * @return
//     */
//    public Collection<GrantedAuthority> mapToGrantedAuthorities(JwtUser jwtUser) {
//
//        System.out.println("--------------------loadPermissionByUser:" + jwtUser.getAppId() + "---------------------");
//        //根据用户id查询角色
//        List<AdminRole> roles = adminRoleService.selectById(jwtUser.getId());
//        //根据角色查询权限
//        List<AdminAuthority> authority = adminAuthorityService.getAuthority(roles);
//
//        List<GrantedAuthority> list = new ArrayList<>();
//        for (AdminAuthority permission : authority) {
//            SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority(permission.getName());
//            list.add(simpleGrantedAuthority);
//        }
//        return list;
//    }
//}
